package com.lntea.jdbc.dbutils;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

public class BeanListHandlerDemo {
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		ResultSetHandler<List<User>> h = new BeanListHandler<User>(User.class);
		QueryRunner queryRunner = new QueryRunner();
		List<User> users = queryRunner.query(ConnectionUtil.getConnection(), "select * from user", h);
		for(User user : users){
			System.out.println(user);
		}
	}
}
